class TvController < ApplicationController
	layout "standard-layout"
	def index
		list
		render :action => 'list'
	end
	def list
	end

	def send_impl(str)
		begin
			sock = TCPSocket.new('localhost', 12346)
			sock.puts(str)
			sock.close()
		rescue
		end
	end

	def turn_off
		send_impl("<tv signal=\"off\"/>")
		render :partial => "list"
	end

	def turn_left
		send_impl("<tv signal=\"vol_down\"/>")
		render :partial => "list"
	end
	def turn_right
		send_impl("<tv signal=\"vol_up\"/>")
		render :partial => "list"
	end

	def turn_up
		send_impl("<tv signal=\"chan_up\"/>")
		render :partial => "list"
	end
	def turn_down
		send_impl("<tv signal=\"chan_down\"/>")
		render :partial => "list"
	end
end

